Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Handling and Test Coverage for CheckoutApiException #174

Conversation

armando-rodriguez-cko
Copy link
Contributor

Description

This PR improves the CheckoutApiException class and its associated tests to ensure more robust error handling for scenarios where API responses are partial or do not contain the expected keys (error_codes or error_type).

Changes Made

  • Enhanced error handling in CheckoutApiException:

    • Replaced direct dictionary access (payload['key']) with payload.get('key') to prevent KeyError in cases of incomplete JSON responses.
    • Ensured error_details and error_type attributes default to None if the corresponding keys are not present in the response payload.
  • Updated unit tests:

    • Covered scenarios where API responses:
      • Do not include keys like error_codes or error_type.
      • Are valid but contain no relevant data.
      • Return empty text or invalid JSON.
  • Improved robustness:

    • Optimized the implementation to handle partial responses gracefully, ensuring a more consistent experience for SDK users.

Impact

  • Improves the stability and robustness of the SDK in error-handling scenarios.
  • Increases unit test coverage for the CheckoutApiException class.
  • Simplifies error diagnostics by explicitly handling edge cases.

Additional Notes

  • This change does not introduce any breaking changes and remains fully backward compatible with existing implementations.

tests/exception_test.py Dismissed Show dismissed Hide dismissed
tests/exception_test.py Dismissed Show dismissed Hide dismissed
tests/exception_test.py Fixed Show fixed Hide fixed
tests/exception_test.py Dismissed Show dismissed Hide dismissed
tests/exception_test.py Dismissed Show dismissed Hide dismissed
tests/exception_test.py Dismissed Show dismissed Hide dismissed
tests/exception_test.py Dismissed Show dismissed Hide dismissed
tests/exception_test.py Dismissed Show dismissed Hide dismissed
tests/exception_test.py Dismissed Show dismissed Hide dismissed
tests/exception_test.py Dismissed Show dismissed Hide dismissed
@armando-rodriguez-cko armando-rodriguez-cko force-pushed the feature/enhancements-to-error-handling-and-test-coverage-for-checkoutapiexception branch from 448c1fd to 353e493 Compare November 19, 2024 14:59
@armando-rodriguez-cko armando-rodriguez-cko force-pushed the feature/enhancements-to-error-handling-and-test-coverage-for-checkoutapiexception branch from 353e493 to f641002 Compare November 19, 2024 15:03
tests/exception_test.py Dismissed Show dismissed Hide dismissed
@armando-rodriguez-cko armando-rodriguez-cko marked this pull request as draft November 19, 2024 15:06
@armando-rodriguez-cko armando-rodriguez-cko marked this pull request as ready for review November 19, 2024 16:58
@armando-rodriguez-cko armando-rodriguez-cko requested a review from a team November 19, 2024 16:59
@armando-rodriguez-cko armando-rodriguez-cko merged commit 90deed4 into main Nov 20, 2024
5 checks passed
@armando-rodriguez-cko armando-rodriguez-cko deleted the feature/enhancements-to-error-handling-and-test-coverage-for-checkoutapiexception branch November 20, 2024 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants